<template>
    <div class="wage-calculator">
        <h1>牛马收益</h1>
        <div class="content">
            <div class="info">
                <div class="info-header">
                    <div class="rol"></div>
                    <div class="line"></div>
                </div>
                <h2>计算公式：</h2>
                <p>工作性价比 = 平均日薪综合环境系数 / 35 * (工作市场+通勤时长-0.5X横鱼时长) * X学历指数</p>
                <h2>最终结果说明：</h2>
                <p>&lt; 0.8 就不幸福<br />> 1.5 说明工作已经很爽了<br />> 2.0 代表有份神仙工作</p>
                <h2>系数说明：</h2>
                <p>平均日薪 = 月薪 / 工作天数<br />综合环境系数 = 工作环境系数 * X异性环境系数 * X同事环境系数<br />各类时间：<br />工作时长 = 下班时间 -
                    上班时间<br />通勤时长 = 上班通勤 + 下班通勤<br />横鱼时长 = 不干活时长 + 吃饭时长 + 午休时长</p>
            </div>
            <div class="calculator-container">
                <div class="calculator">
                    <div class="header">工作性价比计算器</div>
                    <div class="input-group">
                        <label>月薪：（人民币）</label>
                        <input v-model="monthlySalary" placeholder="请输入月薪" />
                    </div>
                    <div class="input-group">
                        <label>每天工作小时数：</label>
                        <input v-model="dailyWorkHours" placeholder="请输入每日工作小时数（例如：8小时：8）" />
                    </div>
                    <div class="input-group">
                        <label>当月上班天数：</label>
                        <input v-model="workDays" placeholder="请输入当月上班天数" />
                    </div>
                    <button @click="calculateRealTimeWage">下一步</button>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
    export default {
        data() {
            return {
                monthlySalary: '',
                dailyWorkHours: '',
                workDays: ''
            };
        },
        methods: {
            calculateRealTimeWage() {
                const { monthlySalary, dailyWorkHours, workDays } = this;
                if (!monthlySalary || !dailyWorkHours || !workDays) {
                    window.alert('检测到输入数据有空值，请填写完整后再提交。');
                    return;
                }
                if (isNaN(dailyWorkHours) || parseFloat(dailyWorkHours) < 0 || parseFloat(dailyWorkHours) > 24) {
                    window.alert('每天工作小时数必须是 0 - 24 之间的数字。');
                    return;
                }
                if (isNaN(workDays) || parseFloat(workDays) < 0 || parseFloat(workDays) > 32) {
                    window.alert('当月上班天数必须是 0 - 32 之间的数字。');
                    return;
                }
                this.$router.push({
                    path: '/priceViewInputPage2',
                    query: {
                        monthlySalary: this.monthlySalary,
                        dailyWorkHours: this.dailyWorkHours,
                        workDays: this.workDays
                    }
                });
            }
        }
    };
</script>

<style scoped>
    * {
        margin: 0;
        padding: 0;
        box-sizing: border-box;
    }

    .content {
        display: flex;
        justify-content: center;
        align-items: flex-start;
        width: 100vw;
        height: 100vh;
    }

    .wage-calculator {
        width: 100vw;
        height: 100vh;
        background-color: #888;
        padding: 20px;
        text-align: center;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
    }

    h1 {
        color: white;
        width: 548px;
        height: 157px;
        font-size: 100px;
        font-family: STXinwei;
    }

    .calculator-container {
        width: 50%;
        height: 80%;
        background-color: white;
        border-radius: 10px;
        box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        margin-left: 20px;
    }

    .info {
        width: 30%;
        height: 80%;
        background-color: white;
        border-radius: 10px;
        padding: 20px;
        box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
        font-size: 20px;
        text-align: left;
    }

    .info-header {
        width: 100%;
        height: 50px;
    }

    .rol {
        width: 50px;
        height: 50px;
        background-color: #f0c040;
        border-radius: 50%;
    }

    .line{
        border-bottom: 5px dashed black ;
    }

    .calculator {
        width: 100%;
        height: 100%;
        background-color: #f9f9f9;
        padding: 20px;
        border-radius: 10px;
    }

    .header {
        width: 100%;
        /* height: 40%; */
        background-color: #f0c040;
        color: white;
        padding: 10px;
        border-radius: 10px;
        font-weight: bold;
        margin-bottom: 20px;
    }

    .input-group {
        width: 100%;
        margin-bottom: 15px;
        text-align: left;
        font-size: 30px;
    }

    input {
        width: 100%;
        height: 80px;
    }

    label {
        display: block;
        margin-bottom: 5px;
        color: #f0c040;
    }

    input {
        width: 100%;
        padding: 8px;
        border: 1px solid #ccc;
        border-radius: 4px;
    }

    button {
        background-color: #f0c040;
        color: white;
        padding: 10px 20px;
        border: none;
        border-radius: 4px;
        cursor: pointer;
    }
</style>